
$(function () {
    initDropDown();
});
function initDropDown() {
    $.ajax({
        url: _server + "/bssp/type/list",
        type: 'post',
        dataType: 'json',
        data: {currentPage:'1'},
        xhrFields: {
            withCredentials: true
        },
        crossDomain: true,
        success: function (result) {
            $.each(result.data, function(i, n) {
                $("#type").append(
                    "<option value=" + n.typecd + ">" + n.typename
                    + "</option>");
            });
            /*$("#type").append(
                "<option value=" + n.genre + ">" + n.genre
                + "</option>");*/
        },
        error: function (result) {
            layer.msg("首页请求失败",{time:1500});
        }
    });
}

function submitData(url){
    $("#fm").form("submit",{
        url:url,
        onSubmit:function(){
            var content= CKEDITOR.instances.detail.getData()
            if(content==""){
                $.messager.alert("系统提示","内容不能为空！");
                return false;
            }
            return $(this).form("validate");
        },
        success:function(result){
            var result=eval('('+result+')');
            if(result.success){
                $.messager.alert("系统提示","保存成功");
                resetValue();
            }else{
                $.messager.alert("系统提示","保存失败");
                return;
            }
        }
    });

}


function resetValue(){
    $("#name").val("");
    $("#summary").val("");
    $("#imageFile").val("");
    $("#score").val("");
    $("#type").val("");
    $("#no").prop("checked", true);
    CKEDITOR.instances.detail.setData("");
}